In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

In [2]:
starting_date = '20160701'
sample_numpy_data = np.array(np.arange(24)).reshape((6,4))
dates_index = pd.date_range(starting_date, periods=6)
sample_df = pd.DataFrame(sample_numpy_data, index=dates_index, columns=list('ABCD'))
sample_df


Out[2]:
A B C D
2016-07-01 0 1 2 3
2016-07-02 4 5 6 7
2016-07-03 8 9 10 11
2016-07-04 12 13 14 15
2016-07-05 16 17 18 19
2016-07-06 20 21 22 23

In [3]:
sample_df_2 = sample_df.copy()
sample_df_2['Fruits'] = ['apple', 'orange','banana','strawberry','blueberry','pineapple']
sample_df_2


Out[3]:
A B C D Fruits
2016-07-01 0 1 2 3 apple
2016-07-02 4 5 6 7 orange
2016-07-03 8 9 10 11 banana
2016-07-04 12 13 14 15 strawberry
2016-07-05 16 17 18 19 blueberry
2016-07-06 20 21 22 23 pineapple

Setting a new column automatically aligns the data by the indexes


In [ ]:


In [ ]:


In [ ]:

Setting values by label

In [ ]:

Setting values by position

documentation: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.iat.html

iat provides integer based lookups


In [ ]:

Setting by assigning with a numpy array

In [ ]:


In [ ]: